#pragma once
#include "Game.h"
class Player
{
private:
	string name;
	int posX, posY;
	deque<char> *queue;

public:

	Player()
	{
		this->name = "";
		this->posX = 0;
		this->posY = 0;
	}
	Player(int x, int y, string c, deque<char> *queue)
	{
		this->posX = x;
		this->posY = y;
		this->name = c;
		this->queue = queue;
	}
	void operator()()
	{
		while (1)
		{
			mutex_cout.lock();
			position p;
			p.player = this->name;
			p.prevX = this->posX;
			p.prevY = this->posY;

			if (queue->empty());
			
			else
			{
				if ((queue->back() == 'w' || queue->back() == 'i'))
				{
					if (posY != 0)
					{
						posY--;
					}
				}
				else if ((queue->back() == 'a' || queue->back() == 'j'))
				{
					if (posX != 0)
					{
						posX--;
					}
				}
				else if ((queue->back() == 's' || queue->back() == 'k'))
				{
					if (posY != 9)
					{
						posY++;
					}
				}
				else if ((queue->back() == 'd' || queue->back() == 'l'))
				{
					if (posX != 9)
					{
						posX++;
					}
				}
				queue->pop_back();
			}

			p.posX = this->posX;
			p.posY = this->posY;
			movesDeque.push_back(p);

			mutex_cout.unlock();
			this_thread::sleep_for(chrono::milliseconds(100));
		}
	}
	~Player()
	{
	}
};

